package com.Interface.TestIO;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.io.FileInputStream;

public class test8 {
    public static void main(String[] args) throws Exception {
        String path = "D:\\JAVA\\schoolSystem\\src\\com\\Interface\\TestIO\\file\\pet.template";
        String path1 = "D:\\JAVA\\schoolSystem\\src\\com\\Interface\\TestIO\\file\\pet.txt";
        InputStream inputStream = new FileInputStream(path);
        OutputStream outputStream = new FileOutputStream(path1);
        Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
        Writer writer = new OutputStreamWriter(outputStream,StandardCharsets.UTF_8);
        StringBuffer stringBuffer = new StringBuffer();
        StringBuilder stringBuilder = new StringBuilder();
        BufferedReader bufferedReader = new BufferedReader(reader);
        BufferedWriter bufferedWriter  = new BufferedWriter(writer);
        String str = null;
        while ((str = bufferedReader.readLine()) != null){
            stringBuilder.append(str);
        }
        System.out.printf("对对对");
        String stringRead = stringBuilder.toString();
        stringRead = stringRead.replace("{name}","{欧欧}");
        stringRead = stringRead.replace("{type}","{狗}");
        stringRead = stringRead.replace("{master}","{张三}");

        writer.write(stringRead);
        writer.flush();
        writer.close();
        reader.close();


    }
}
